   @extends('common.common')
   @section('title','订单支付')
   @section('css')<link rel="stylesheet" href="{{asset('/css/WXpay.css')}}">@endsection
   @section('content')
    <div id="content">
        @include('common.centernav')
        <?php
        $notify = new NativePay();
        $url1 = $notify->GetPrePayUrl("123456789");
        $input = new WxPayUnifiedOrder();
        $input->SetBody($param['name']);
        $input->SetAttach($param['orders_orderNo']);
        $input->SetOut_trade_no($param['orders_orderNo']);
        $input->SetTotal_fee($param['orders_amount'] *100);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 1200));
        $input->SetGoods_tag("test");
        $input->SetNotify_url("http://www.mzujie.com/wxnotify");
        $input->SetTrade_type("NATIVE");
        $input->SetProduct_id("123456789");
        $result = $notify->GetPayUrl($input);
        $url2 = $result["code_url"];
        ?>
        <h3>订单支付</h3>
        <div class="container">
            <div class="row">
                <!--2、右侧主体-->
                <div class="col-xs-12">
                    <!--右侧面版-->
                    <div class="panel panel-default rightPanel">
                        <div class="panel-heading">
                            <h4>微信支付</h4>
                        </div>
                        <div id="pay" class="panel-body">
                            <div class="order">
                                <span>订单提交成功，请尽快支付！订单号：</span>
                                <span>{{$param['orders_orderNo']}}</span>
                            </div>
                            <div class="pay">
                                <div class="pay_pic">
                                    <div>距离二维码过期还有两个小时，过期后请刷新页面重新获取二维码</div>
                                    <div class="border">
                                        <img alt="模式二扫码支付" src="{{asset('/wxpay/example/qrcode.php')}}?data=<?php echo urlencode($url2);?>"/>
                                    </div>
                                </div>
                                <div class="phone">
                                    <img src="/img/phone.png" alt="">
                                </div>
                            </div>
                        </div>
                        <div class="panel-footer">
                            <p class="pull-right">
                                <span>应付金额：</span>
                                <span class="red">¥&nbsp;{{$param['orders_amount']}}</span>
                                <a href="#" class="btn btn-warning">订单详情</a>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" name="out_trade_no" id="out_trade_no" value="{{$param['orders_orderNo']}}" />
    <script src="{{asset('/js/jquery-1.11.3.js')}}"></script>
    <script>
        $(function(){
            setInterval(function(){check()}, 5000);  //5秒查询一次支付是否成功
        })
        function check(){
            var out_trade_no = $('#out_trade_no').val();
            $.post('/wxnotify',{out_trade_no:out_trade_no,'_token':'{{csrf_token()}}'},function (data) {
                if (data == "成功"){
                    setTimeout(function () {
                        alert('订单支付成功，正在跳转....');
                        window.location.href ="http://laravel.com/user/order";
                    },1000);
                }
            });
        }
    </script>
   @endsection